/*
 * Copyright (c) 2008 Openviewing
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Created: 09-Apr-2005 16:30:49
 */
package org.openviewing.foundation.control.factory;

import java.util.Map;

/** Bean Registry Strategy.
 *
 *  <p>This interface oulines the behavioral strategy [GOF] design pattern for a java bean registry [FOWLER] that follows the factory method [GOF] design pattern.</p>
 *  <p>References</p>
 *  <ul>
 *      <li><b>[FOWLER]</b> Fowler, Martin. <i>Patterns Of Enterprise Application Architecture.</i> Addison-Wesley, 2003.</li>
 *      <li><b>[GOF]</b> Gamma, Erich. Helm, Richard. Johnson, Ralph. Vlissides, Johhn. <i>Design Patterns, Elements of reuable Object-Oriented Software</i> Addison-Wesley, 1995.</li>
 *  </ul>
 */
public interface BeanRegistryStrategy
{
    /** Bean creator.
     *
     *  Retrieve the bean with the given name.
     *
     *  @param    name    The logical name of the bean to be retrieved.
     *  @return    The generated bean as defined by its configuration.
     */
    public Object getBean(String name);
    /** Bean creator.
     *
     *  Retrieves the bean with the given name and class.
     *
     *  @param    name            The logical name of the bean to be retrieved.
     *  @param    classType    The required class type to be retrieved.
     *  @return    The generated bean as defined by its configuration.
     */
    public Object getBean(String name, Class<?> classType);
    /** Bean creator.
     *
     *  Retrieves the bean of the given name using the constructor matching args.
     *
     *  @param    name    The logical name of the bean to be retrieved.
     *  @param    args    The arguments passed to the constructor.
     *  @return    The generated bean as defined by its configuration.
     */
    public Object getBean(String name, Object[] args);
    /** Bean creator.
     *
     *  Retrieves the bean with the given name and class using the constructor matching args.
     *
     *  @param    name    The logical name of the bean to be retrieved.
     *  @param    type    The required class type to be retrieved.
     *  @param    args    The arguments passed to the constructor.
     *  @return    The generated bean as defined by its configuration.
     */
    public Object getBean(String name, Class<?> type, Object[] args);
    /** Bean creator.
     *
     *  Retrieves the bean with the given name using the mutators matching key name i.e.setKeyname
     *  @param    name        The logical name of the bean to be retrieved.
     *  @param    attributes    Map of attributes as the keys and the value to be set.
     *  @return    The generated bean as defined by its configuration and the given attributes.
     */
    public Object getBean(String name, Map<String, Object> attributes);
    /** Bean registration.
     *
     *  This adds the bean to the registry.
     *
     *  @param    name    The reference name of the bean used through out the application.
     *  @param    type    The class type of the bean.
     */
    public void addBean(String name, String type); // TODO change this to use a bean definition instead of type.
}
